/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chameleon.model.NuGatStructure.symbTable;

import chameleon.model.NuGatStructure.utils.Node;
import chameleon.gameSolver.NuGat.NuGatInterface;
import chameleon.model.NuGatStructure.NuGatStructure;
import com.sun.jna.Pointer;

/**
 * This class is wrapper to the NuSmv struct SymbType written by Andrei Tchaltsev.
 * 
 * This class represent the types of the NuSMV type system.
  The types can be:
    a) enum (enumeration), that represents a set of particular values, e.g.
       . a boolean enumeration type: {0,1}
       . a pure symbolic enumeration type: {A, OK, CORRECT, FAIL}
       . a pure integer enumeration type: {1,2,3,4,5, 10, -1, 0}
       . an integer and symbolic enumeration type: {0, 2, 4, OK, FAIL}
    b) integer, that represents the infinite-precision integer arithmetic.
    c) real, that represents the infinite-precision rational arithmetic.
    d) word of width N (N is an integer positive number), that represents
       bit vectors of N bits.
    e) WordArray of address word of width M and value word of width N
       (with M and N integer positive numbers), that represents a
       memory array of 2^M locations, each of which contains a word of
       M bits.
    f) Array represents array of fixed lower and upper bounds 
       and elements of a particular type.
    g) Set types created by "union" expressions and used in "in", "case"
        and ":=" expressions:
       . a set of boolean values :  0 union 1
       . a set of integer values :  0 union -1 union 10
       . a set of symbolic values :  OK union FAIL
       . a set of integer and symbolic values: OK union 1
       Note that only expressions (not declared variables) can
       have these types.
    h) No-type is an artificial type to represent expressions which usually 
       do not have any type (for example, assignments).
    i) Error type is an artificial type to represent erroneous
       situations.


  A type can be created with the class' constructor. In the case of a
  enum type, during construction it is necessary to specify explicitly the
  list of values this type consists of.

  The constructor is typically used in a symbol table.

  Another possibility is to obtain the types with
  SymbTablePkg_..._type functions. In this case, the enum types will be
  "abstract", i.e. they will consist of some artificial (not existing)
  values. The important feature is that the memory is shared by these
  functions, i.e. you can compare pointers to types, instead of the
  types' contents.  These functions are mostly used in type checking
  (since the particular values of enum types are of no importance). 
 * 
 * 
 * 
 * @author simon
 */
public class SymbType extends NuGatStructure {
    
    public SymbType(Pointer type, NuGatInterface nugat){
        super (type, nugat);
    }
    
    /**Function********************************************************************

       Synopsis    [Class SymbType constructor]

       Description [The tag must be a correct tag. The 'body' is the
       additional info corresponding to a particular kind of the type:
       * for a enum type the body is the list of values;
       * for boolean type it is special variable boolean_range,
       * for "INT" or "REAL" the body is unused, and set to Nil;
       * for signed and unsigned "WORD" it is the NUMBER node defining the
          width of the type;
       * for "WORDARRAY", the body is a pair of NUMBER nodes, defining
          the width of the address, and the width of the value.
       * for everything else body is Nil;

       Note that array types have to be created with
       SymbType_create_array, not with this constructor.

       Set-types are used with expressions which represent a set values.
       "NO-TYPE" is used with expressions which normally do not
            have any type such as assignments.
       "ERROR" type indicates an error (not an actual type).

       No-type, error-type and all set-types (boolean-set, integer-set,
       symbolic-set, symbolic-integer-set) should not be created with this
       constructor, but only with memory-shared function
       SymbTablePkg_..._type.  The reason behind this constrain is that
       only expressions (not variables) can have these types, therefore
       only memory-shared versions of these types are required.

       The constructor does not create a copy of the body, but just remember
       the pointer.

       NB: system "reset" command destroys all node_ptr objects, including those
       used in SymbType_ptr. So destroy all symbolic types before the destruction
       of node_ptr objects, i.e. before or during "reset"]

       SideEffects        [allocate memory]

       SeeAlso            [SymbType_create_array, SymbType_destroy]

    ******************************************************************************/
    
    public SymbType(int SymbTypeTag_tag, Node body, NuGatInterface nugat){
        super (nugat.SymbType_create(SymbTypeTag_tag, body.ptr()),nugat);        
    }
}
